*********************
** Figure A.1: Relationship between out-group discrimination derived from tasks 1 and 2 (vertical axis) and out-group discrimination derived from task 3 (horizontal axis)
*********************

	preserve
			
		egen Giving_group = group(Game12_GivingInMinusGivingOut Game3_Giving_2_5_MinusGivingOut)

		gen count = 1
		bysort Giving_group: egen Giving_obs = sum(count)

		keep Game12_GivingInMinusGivingOut Game3_Giving_2_5_MinusGivingOut Giving_obs Giving_group 
		
		duplicates drop *, force
		
		sort Game12_GivingInMinusGivingOut Game3_Giving_2_5_MinusGivingOut
		
		gen Ave_Giving_obs = Giving_obs / 456
		

		twoway 		(scatter  	Game12_GivingInMinusGivingOut Game3_Giving_2_5_MinusGivingOut [w = Ave_Giving_obs]	,	msize(vsmall)) 	///
					 , ylab(-5(1)5, nogrid valuelabels) xlab(-2.5(0.5)2.5, valuelabels) yscale(range(-5(1)5)) xscale(range(-2.5(1)2.5)) graphregion(color(white)) xtitle("Game 3: (Giving to In-Group - Giving to Out-Group) / 2") ytitle("Game 1&2: Giving to In-Group - Giving to Out-Group") ///
					note(" ")
		 
		graph export "2_output\FigureA1.pdf", replace
				
	restore
	
	
*********************
** Figure A.2: Distribution of choices in tasks 1-3, conditional on shift (morning or afternoon) and on recipient’s group memberships
*********************

gen Shift_Label = shift
gen Fig_Game12_Giving_In 	= Game12_Giving_In
gen Fig_Game12_Giving_Out 	= Game12_Giving_Out
gen Fig_Game3_Giving_Out 	= Game3_Giving_Out

label def Shift_Label 0 "Morning Shift (Jordanians)" 1 "Afternoon Shift (Syrians)"
label val Shift_Label Shift_Label

label var Fig_Game12_Giving_In 		"Amount given to in-group child"
label var Fig_Game12_Giving_Out 	"Amount given to out-group child"
label var Fig_Game3_Giving_Out 		"Amount given to out-group child"


* (a) Unconditional distribution of giving to the in-group in tasks 1/2 (by shift)

	histogram Fig_Game12_Giving_In												///
				, discrete													///
				by(Shift_Label, note(" ") title("Giving to the In-Group Child (Tasks 1 and 2)"))		///
				ytitle("Density")		xlabels(0(1)5)	xscale(range(0 6)) ylabels(0(0.1)0.8) graphregion(color(white))	 scheme(s1mono)	
				
	graph save 		"2_output\FigureA2a_Giving_In_Group_MorningVsAfternoon", replace


* (b) Unconditional distribution of giving to the out-group in tasks 1/2 (by shift)

	histogram Fig_Game12_Giving_Out												///
				, discrete													///
				by(Shift_Label, note(" ") title("Giving to the Out-Group Child (Tasks 1 and 2)"))		///
				ytitle("Density")		xlabels(0(1)5) xscale(range(0 6))  ylabels(0(0.1)0.8)	graphregion(color(white))	 scheme(s1mono)		

	graph save 		"2_output\FigureA2b_Giving_Out_Group_MorningVsAfternoon", replace			

	
* (c) Distribution of giving to the out-group in Task 3 

	histogram Fig_Game3_Giving_Out												///
				, discrete													///
				by(Shift_Label, note(" ") title("Giving to the Out-Group Child (Task 3)"))		///
				ytitle("Density")		xlabels(0(1)5) xscale(range(0 6)) ylabels(0(0.1)0.8)	graphregion(color(white))	 scheme(s1mono)		

	graph save 		"2_output\FigureA2c_Game3_Giving_Out_Group_MorningVsAfternoon", replace


* (1c) Combination of the figures above

	graph combine 	"2_output\FigureA2a_Giving_In_Group_MorningVsAfternoon" 				///
					"2_output\FigureA2b_Giving_Out_Group_MorningVsAfternoon"				///
					"2_output\FigureA2c_Game3_Giving_Out_Group_MorningVsAfternoon"			///
	, col(1) iscale(0.5) graphregion(color(white))

	graph export "2_output\FigureA2.pdf", replace

cap drop Fig_Game12_Giving_* Fig_Game3_Giving_Out Shift_Label
cap erase "2_output\FigureA2a_Giving_In_Group_MorningVsAfternoon.gph"
cap erase "2_output\FigureA2b_Giving_Out_Group_MorningVsAfternoon.gph"
cap erase "2_output\FigureA2c_Game3_Giving_Out_Group_MorningVsAfternoon.gph"


*********************
** Figure A.3: Distribution of responses to questions discussed in Table 2 (Parental Attitudes)
*********************	

* The Syrian Crisis is a Tragedy

histogram ParAtt_Tragedy					///
			, 		discrete fraction								///
			by(shift, note(" ") title("Jordanians should help as much as possible", size(medium)))	///
			ytitle("Fraction")		xtitle("Agreement with statement")			///
			xlabels(1(1)10)  ylabels(0(0.1)0.7) graphregion(color(white))	 scheme(s1mono)	
			
	graph save "2_output\FigureA3a_SyrianCrisisTragedy", replace		

* Jordanians have already done enough

histogram ParAtt_JordanDoneEnough				///
			, 		discrete fraction								///
			by(shift, note(" ") title("Jordanians have already done enough", size(medium)))	///
			ytitle("Fraction")		xtitle("Agreement with statement")			///
			xlabels(1(1)10)  ylabels(0(0.1)0.7) graphregion(color(white))	 scheme(s1mono)	
			
	graph save "2_output\FigureA3b_JordaniansDoneEnough", replace			
	
* Syrian crisis has increased rental prices

histogram ParAtt_RentalPrice				///
			, 		discrete fraction								///
			by(shift, note(" ") title("Crisis has increased rental prices", size(medium)))	///
			ytitle("Fraction")		xtitle("Agreement with statement")			///
			xlabels(1(1)10)  ylabels(0(0.1)0.7) graphregion(color(white))	 scheme(s1mono)	
			
	graph save "2_output\FigureA3c_CrisisIncreasedRentalPrices", replace		
	
* Syrian crisis has increased rental prices

histogram ParAtt_Jobs				///
			, 	discrete fraction									///
			by(shift, note(" ") title("Crisis has reduced job availability", size(medium)))	///
			ytitle("Fraction")		xtitle("Agreement with statement")			///
			xlabels(1(1)10)  ylabels(0(0.1)0.7) graphregion(color(white))	 scheme(s1mono)	
			
	graph save "2_output\FigureA3d_SyrianCrisisJobs", replace		


graph combine 		"2_output\FigureA3a_SyrianCrisisTragedy" 				///
					"2_output\FigureA3b_JordaniansDoneEnough"				///
					"2_output\FigureA3c_CrisisIncreasedRentalPrices"		///
					"2_output\FigureA3d_SyrianCrisisJobs"

					
	graph export "2_output\FigureA3.pdf", replace	

	
cap erase "2_output\FigureA3a_SyrianCrisisTragedy.gph"
cap erase "2_output\FigureA3b_JordaniansDoneEnough.gph"
cap erase "2_output\FigureA3c_CrisisIncreasedRentalPrices.gph"
cap erase "2_output\FigureA3d_SyrianCrisisJobs.gph"

* Have a nice day!